#!/bin/bash
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3
PATH="/bin:/sbin:/usr/bin:/usr/sbin"

Ok_name=''
Fail_name=''
Judge=0
TTimeout=13
HName=`/bin/hostname -s`

function mount_l() {
		Temp=`/bin/mount -l|grep -w $2 |grep $1`
		if [ "t$Temp" == "t" ]
		then
                        Judge=1
                        Fail_name="${Fail_name} ${choice}"
                else
                        Ok_name="${Ok_name} ${choice}"
                fi
                       
		#continue

}



if [ -e /etc/init.d/lustre ]
then

Lmount=`cat /etc/init.d/lustre  |grep "nms check"|awk -F : '{print $2}'`
#Lmount="scratchfs besfs" #dont forget if -e /etc/init.d/lustre
#for choice in besfs bes3fs publicfs besfs2 dybfs scratchfs workfs cefs  dyfs2 hpcfs 
        ###
for choice in $Lmount
do
	case $choice in
        dyfs2)
                mount_l  rw "dybfs2"   # /etc/init.d/lustre not right
                ;;

        workfs2)
                mount_l  r "$choice" #can not ro because login nodes are rw
                ;;
       *)
                mount_l  rw "$choice"
                ;;


	esac

done


if [ $Judge -eq 1 ]
then
	echo "mount -l $Fail_name  wrong status"
	exit $CRITICAL
else
	echo " $Ok_name are OK "
	exit $OK
fi

else
	echo "can not find file /etc/init.d/lustre"
	exit $CRITICAL
fi
